<!-- shipCertificateSee -->

<template>
  <div class="loadHomeWork">
    <div class="loadHomeWorkIneer">
      <div class="loadTop">{{ pageName }}</div>
      <div class="loadExcel">
        <div class="button" type="success" @click="uploadFile()">导入</div>
        <div class="button" type="success" @click="getExcelFile()">导出</div>
        <div class="button" type="success" @click="addOne()">新增</div>
        <div class="multiButton" type="success" @click="deleteMulti()">
          删除
        </div>
        <div class="buttonBack" @click="backIndex()">返回</div>
      </div>
      <div class="table" :style="{ width: tableWidth }">
        <el-table
          empty-text="暂无数据"
          :header-cell-style="{
            background: '#FAFAFA',
            color: '#777676 !important',
            fontWeight: '800',
          }"
          :data="tableData"
          border
          stripe
          style="width: 100%; height: auto"
          max-height="65vh"
          @row-dblclick="handleRowDblclick"
          @selection-change="selecttableFunction"
          :row-style="{ height: 30 + 'px' }"
          :cell-style="{ padding: 0 + 'px' }"
          ><el-table-column type="selection" width="35" align="center" />
          <el-table-column
            type="index"
            :index="indexNumber"
            align="center"
            label="序号"
            max-width="55"
          >
          </el-table-column>
          <el-table-column
            prop="fillShip"
            label="加注船"
            align="center"
            min-width="100"
          />
          <el-table-column
            prop="reportName"
            label="报告名称"
            min-width="300"
            align="center"
          >
          </el-table-column>
          <el-table-column
            prop="startPoint"
            label="起始地"
            align="center"
            min-width="100"
          />
          <el-table-column
            prop="channel"
            label="航道"
            align="center"
            min-width="100"
          />
          <el-table-column
            prop="totalVoyage"
            label="总航程"
            align="center"
            min-width="100"
          />
          <el-table-column
            prop="voyageTime"
            label="航行时间"
            :formatter="formatDate"
            align="center"
            min-width="100"
          />
          <!-- totalVoyage -->
          <el-table-column
            prop="destination"
            label="目的地"
            align="center"
            min-width="100"
          />

          <el-table-column
            label="完成情况"
            min-width="100"
            prop="completionStatus"
            align="center"
          />
          <el-table-column
            label="完成时间"
            min-width="100"
            prop="completionTime"
            align="center"
          />
          <el-table-column
            label="评估公司"
            min-width="150"
            prop="assessCompany"
            align="center"
          />
          <el-table-column
            label="通航评估报告编号"
            min-width="150"
            prop="reportNum"
            align="center"
          />
        </el-table>
        <!-- 内容过多，会出现滚动条 -->
      </div>
      <div class="foot">
        <div class="currentPage">当前第{{ page }}/{{ totalPages }}页</div>
        <div
          class="lastPage"
          :style="{ background: color }"
          @click="clickLastPage()"
        >
          上一页
        </div>
        <div
          class="nextPage"
          :style="{ backgroundColor: color1 }"
          @click="clickNextPage()"
        >
          下一页
        </div>
        <div class="currentNumber">共{{ totalNumber }}条</div>
        <div>跳转至:</div>
        <input
          type="text"
          class="skipPage"
          style="width: 50px !important"
          v-model="shipPageNumer"
        />
        <div class="sureSkip" @click="skipPage">确定</div>
      </div>
    </div>
    <div class="dialog" ref="dialog" :style="{ display: show }">
      <div class="loadHomeWorkIneer">
        <div class="changeTop">
          <div
            class="delete"
            @click="deleteOne(id)"
            v-show="addOrEdit == '编辑'"
          >
            删除
          </div>
          <div class="sure" @click="sureAdd()">确认</div>
          <div class="back" @click="backToIndex()">返回</div>
        </div>
        <div class="dialogText">通航评估报告</div>
        <div class="manyInput">
          <div class="iuptInnerContain">
            <div class="inputInner">
              <div class="name">报告名称:</div>
              <input type="text" placeholder="报告名称" v-model="reportName" />
            </div>

            <div class="inputInner">
              <div class="name">加注船:</div>
              <input type="text" placeholder="加注船" v-model="fillShip" />
            </div>

            <div class="inputInner">
              <div class="name">起始地:</div>
              <input type="text" placeholder="起始地" v-model="startPoint" />
            </div>
            <div class="inputInner">
              <div class="name">航道:</div>
              <input type="text" placeholder="航道" v-model="channel" />
            </div>
            <div class="inputInner">
              <div class="name">目的地:</div>
              <input type="text" placeholder="目的地" v-model="destination" />
            </div>
            <div class="inputInner">
              <div class="name">总航程:</div>
              <input type="text" placeholder="总航程" v-model="totalVoyage" />
            </div>
            <div class="inputInner">
              <div class="name">航行时间:</div>
              <input
                type="text"
                placeholder="航行时间(min)"
                v-model="voyageTime"
              />
            </div>
            <div class="inputInner">
              <div class="name">完成情况:</div>
              <input
                type="text"
                placeholder="完成情况"
                v-model="completionStatus"
              />
            </div>
            <div class="inputInner">
              <div class="name">完成时间:</div>
              <div class="inputContainer">
                <el-config-provider :locale="locale">
                  <el-date-picker
                    v-model="completionTime"
                    type="month"
                    placeholder="完成时间"
                    format="YYYY/MM"
                    value-format="YYYY/MM"
                  />
                </el-config-provider>
              </div>
            </div>

            <div class="inputInner">
              <div class="name">评估公司:</div>
              <input
                type="text"
                placeholder="评估公司"
                v-model="assessCompany"
              />
            </div>
            <div class="inputInner">
              <div class="name">通航评估报告编号:</div>
              <input
                type="text"
                placeholder="通航评估报告编号"
                v-model="reportNum"
              />
            </div>
          </div>
          <div class="pictureContainner">
            <div
              class="inputInner"
              style="width: 100%; justify-content: center"
            >
              <div class="name6" @click="clickOpenFile(1)">上传航路图</div>
              <div
                class="name6"
                style="margin-left: 10px"
                @click="
                  seePic(
                    this.$base +
                      '/download/assessmentReport/' +
                      this.routeChartImg
                  )
                "
              >
                查看
              </div>
            </div>
            <div class="tonghangImgContain">
              <img :src="src1" alt="" width="100%" height="" />
            </div>

            <div
              class="inputInner"
              style="width: 100%; justify-content: center"
            >
              <div class="name6" @click="clickOpenFile(2)">上传评估报告</div>
              <div
                class="name6"
                style="margin-left: 10px"
                @click="
                  seePic(
                    this.$base +
                      '/download/assessmentReport/' +
                      this.assessmentReportImg
                  )
                "
              >
                查看
              </div>
            </div>
            <!-- <div class="tonghangImgContain">
              <img :src="src2" alt="" width="100%" style="display: none" />
            </div> -->
          </div>
        </div>
      </div>
    </div>

    <div class="dialog2" :style="{ display: uploadfile }">
      <div class="upContain">
        <input
          type="file"
          ref="clearFile"
          class="addfile"
          @change="getFile($event)"
          accept=".xls,.xlsx"
        />
      </div>
      <div class="fileName">
        <div v-show="fileName">文件名:{{ fileName }}</div>
      </div>
      <div class="upFileSrue">
        <button class="buttonUpdata" @click="cancelUp()">取消</button>
        <button class="buttonUpdata buttonUpdata1" @click="submitAddFile()">
          确定
        </button>
      </div>
    </div>
    <div class="dialog3 dialog6" :style="{ display: uploadfile1 }">
      <div class="upContain">
        <input
          type="file"
          ref="clearFile"
          id="addfile"
          accept=".png, .jpeg, .jpg"
          @change="getFile1($event)"
          style="text-indent: 0px"
        />
      </div>
      <div class="fileName">
        <div v-show="fileName1">{{ fileName1 }}</div>
      </div>
      <div class="upFileSrue">
        <button class="buttonUpdata" @click="cancelUp()">取消</button>
        <button class="buttonUpdata buttonUpdata1" @click="subMitPic()">
          确定
        </button>
      </div>
    </div>
    <div class="dialog4 dialog6" :style="{ display: changeFileUp }">
      <div class="changeFileContain">
        <div class="upContain">
          <input
            type="file"
            ref="clearFile"
            id="addfile"
            @change="getFile1($event)"
            style="text-indent: 0px"
          />
        </div>
        <div class="fileName">
          <div v-show="fileName1">{{ fileName1 }}</div>
        </div>
        <div class="upFileSrue">
          <button class="buttonUpdata" @click="cancelUp()">取消</button>
          <button class="buttonUpdata buttonUpdata1" @click="subMitPic()">
            确定
          </button>
        </div>
      </div>
    </div>
  </div>
</template>

<script>
import EventBus from "@/mitt/eventBus.js";
import rename from "@/mitt/getPath.js";
import service from "@/api/api";
import _ from "lodash";

import zhCn from "element-plus/es/locale/lang/zh-cn";
import axios from "axios";
// import userName from "@/assets/img/userName.png";
export default {
  name: "",
  data() {
    return {
      compare: {},
      shipPageNumer: 1,
      pageName: "",
      multi: [],
      totalNumber: 0,
      locale: zhCn,
      token: "",
      tableData: [],
      tableWidth: null,
      page: 1,
      size: 20,
      pageList: [],
      show: "none",
      addOrEdit: "新增",
      currentNum: 0,
      fillShip: "",
      reportName: "",
      completionStatus: "",
      completionTime: "",
      assessCompany: "",
      startPoint: "",
      channel: "",
      totalVoyage: "",
      voyageTime: "",
      destination: "",
      reportNum: "",
      routeChartImg: "",
      id: "",
      totalPages: null,
      type: null,
      uploadfile: true,
      assessmentReportImg: "",
      old: [],
      new: [],
      src1: null,
      src2: null,
      data: {
        fillShip: "",
        reportName: "",
        completionStatus: "",
        completionTime: "",
        assessCompany: "",
        startPoint: "",
        channel: "",
        destination: "",
        reportNum: "",
        routeChartImg: "",
        assessmentReportImg: "",
        deleteRemove: "",
        type: null,
        totalVoyage: "",
        voyageTime: "",
        destination: "",
        reportNum: "",
        id: "",
      },
      whichnum: null,
      deletenumber: 0,
      show1: "none",
      color: "#EBEBEB",
      color1: "#EBEBEB",
      file: null,
      fileName: "",
      jtData: null,
      uploadfile1: "none",

      fill1: null,
      fileName1: "",
      upFileList: [],
      upFileListName: [],
      showFile: "none",
      changeFileText: "",
      changeFileUp: "none",
      editAddNewFIle: false,
    };
  },

  methods: {
    backIndex() {
      this.$router.push("/app.harbourSee");
    },
    formatDate(row, column) {
      // 获取单元格数据

      let data = row[column.property];

      if (data == null) {
        return null;
      } else if (!data) {
        return null;
      }
      if (data < 60) {
        return data + "分钟";
      } else if (data % 60 == 0) {
        return data / 60 + "小时";
      } else {
        return Math.floor(data / 60) + "小时" + (data % 60) + "分钟";
      }
    },
    seePic(a) {
      if (
        a == this.$base + `/download/assessmentReport/null` ||
        a == this.$base + `/download/assessmentReport/undefined` ||
        a == this.$base + `/download/assessmentReport/` ||
        a == this.$base + `/download/assessmentReport/ `
      ) {
        return this.$message({
          message: "未上传对应文件",
          type: "error",
        });
      }
      const link = document.createElement("a");
      link.href = a;
      link.target = "blank";
      document.body.appendChild(link);
      link.click();
      document.body.removeChild(link);
    },
    deleteRomoteNewFile() {
      let data = {
        fileName: this.new[this.deletenumber],
        type: 5,
      };

      service({
        method: "delete",
        url: `/system/delete-file`,
        params: data,
      }).then((r) => {
        if (r.status == "SUCCESS") {
          this.deletenumber++;
          if (this.deletenumber < this.new.length) {
            this.deleteRomoteNewFile();
          } else {
            this.new = [];
            this.deletenumber = 0;
          }
        }
      });
    },
    deleteRomoteOldFile() {
      let data = {
        fileName: this.old[this.deletenumber],
        type: 5,
      };
      service({
        method: "delete",
        url: `/system/delete-file`,
        params: data,
      }).then((r) => {
        if (r.status == "SUCCESS") {
          this.deletenumber++;
          if (this.deletenumber < this.old.length) {
            this.deleteRomoteOldFile();
          } else {
            this.old = [];

            this.deletenumber = 0;
          }
        }
      });
    },
    // 上传图片
    subMitPic() {
      let data = {
        file: this.file,
        type: 5,
        fileName: "",
      };

      service({
        method: "post",
        url: "/system/upload-file",
        headers: {
          "Content-Type": "multipart/form-data",
        },
        data: data,
      })
        .then((res) => {
          this.$message({
            message: "文件选择成功",
            type: "success",
          });
          document.getElementById("addfile").value = "";
          this.fileName = "";
          if (this.whichnum == 1) {
            this.old.push(this.routeChartImg);
            this.new.push(res.data);
            this.routeChartImg = res.data;

            this.src1 = this.$base + "/download/assessmentReport/" + res.data;
          } else if (this.whichnum == 2) {
            this.old.push(this.assessmentReportImg);
            this.new.push(res.data);
            this.assessmentReportImg = res.data;
            this.src2 = this.$base + "/download/assessmentReport/" + res.data;
          }
          document.getElementById("addfile").value = "";
          this.fileName1 = "";
          this.file = "";
          this.uploadfile1 = "none";
        })
        .catch((err) => {
          document.getElementById("addfile").value = "";
          this.fileName1 = "";
          this.file = "";
          this.uploadfile1 = "none";
          this.$message({
            message: err,
            type: "fail",
          });
        });
    },
    clickOpenFile(num) {
      this.uploadfile1 = "block";
      this.whichnum = num;
    },
    indexNumber(index) {
      return (this.page - 1) * this.size + index + 1;
    },

    handleRowDblclick(row) {
      this.clickEdit(row.id);
    },
    skipPage() {
      if (this.shipPageNumer <= this.totalPages && this.shipPageNumer > 0) {
        this.page = this.shipPageNumer;
        this.getRenderList();
      } else {
        this.$message({
          type: "warning",
          message: "超出页面数量范围",
        });
      }
    },
    // 批量删除开始========================
    selecttableFunction(row) {
      if (row.length > 0) {
        this.multi = [];
        row.forEach((element) => {
          this.multi.push(element.id);
        });
      } else {
        this.multi = [];
      }
    },
    deleteMulti() {
      // let that = this;
      if (this.multi.length == 0) {
        return this.$message({
          type: "warning",
          message: "请先选中再进行批量删除操作！",
        });
      }
      let data = {
        idList: this.multi + "",
      };

      this.$alert("确定删除这条信息？", {
        confirmButtonText: "确定",
        callback: (action) => {
          if (action == "confirm") {
            service({
              method: "delete",
              url: `/assessment-report`,
              params: data,
            }).then((r) => {
              if (r.status == "SUCCESS") {
                this.$message({
                  type: "success",
                  message: "删除成功",
                });
                if (this.currentNum == this.multi.length && this.page > 1) {
                  this.page--;
                }
                this.getRenderList();
              }
            });
          } else {
            this.$message({
              type: "info",
              message: "取消删除",
            });
          }
        },
      });
    },
    //批量删除结束=============================
    // 上传pdf图片等文件开始==================================================
    clickDeleteFile(a, b) {
      let data = {
        type: 5,
        fileName: b,
      };
      let num = this.upFileListName.indexOf(b);
      this.upFileListName.splice(num, 1);
      this.upFileList.splice(num, 1);
      service({
        method: "delete",
        url: "/system/delete-file",
        params: data,
      })
        .then((e) => {})
        .catch((e) => {});
    },

    // 更改文件
    changeFile(a, b) {
      this.changeFileText = b;
      this.changeFileUp = "block";
    },
    closeDialog5() {
      this.showFile = "none";
    },

    getFile1() {
      this.file = event.target.files[0];
      this.fileName1 = this.file.name;
      document.getElementsByClassName("addfile")[0].value = "";
    },

    // 上传图片PDF文件结束===================================================
    // 上传excel文件

    customIndex(index) {
      return (this.page - 1) * this.size + index + 1;
    },
    // 导入文件================
    uploadFile() {
      this.uploadfile = "block";
    },
    getFile(event) {
      this.file = event.target.files[0];
      this.fileName = this.file.name;
    },
    submitAddFile() {
      if (this.file) {
        let data = {
          file: this.file,
        };
        service({
          method: "post",
          url: "/assessment-report/upload",
          headers: {
            "Content-Type": "multipart/form-data",
          },
          data: data,
          params: {
            type: this.type,
          },
        })
          .then((res) => {
            document.getElementsByClassName("addfile")[0].value = "";
            this.$message({
              message: "上传成功",
              type: "success",
            });
            this.file = "";
            this.fileName = "";
            this.uploadfile = "none";
            this.getRenderList();
          })
          .catch((err) => {
            this.$message({
              message: err,
              type: "error",
            });
          });
      } else {
        this.$message({
          message: "请先选择文件再上传",
          type: "warning",
        });
      }
    },
    cancelUp() {
      this.file = "";
      this.fileName = "";
      this.fileName1 = "";
      document.getElementById("addfile").value = "";
      this.uploadfile = "none";
      this.uploadfile1 = "none";
      this.changeFileUp = "none";
    },
    backToIndex() {
      if (this.addOrEdit == "编辑") {
        let data = {
          fillShip: this.fillShip,
          reportName: this.reportName,
          completionStatus: this.completionStatus,
          completionTime: this.completionTime,
          assessCompany: this.assessCompany,
          startPoint: this.startPoint,
          channel: this.channel,
          destination: this.destination,
          reportNum: this.reportNum,
          routeChartImg: this.routeChartImg,
          assessmentReportImg: this.assessmentReportImg,
          totalVoyage: this.totalVoyage,
          voyageTime: this.voyageTime,
        };
        let equal = _.isEqual(data, JSON.parse(this.compare));
        if (equal) {
          this.close();
        } else {
          this.$confirm("数据信息有变化是否保存再离开？", "提示", {
            confirmButtonText: "确定",
            cancelButtonText: "取消",
            // type: "warning",
          })
            .then(() => {
              this.sureAdd();
            })
            .catch(() => {
              this.close();
            });
        }
      } else if (this.addOrEdit == "新增") {
        this.close();
      }
    },

    // 导入文件结束=============
    clickEdit(a) {
      this.upFileList = [];
      this.deletenumber = 0;
      this.upFileListName = [];
      this.old = [];
      this.addOrEdit = "编辑";
      this.src1 = "";
      this.src2 = "";
      this.tableData.forEach((item) => {
        if (item.id == a) {
          this.routeChartImg = item.routeChartImg;

          if (item.routeChartImg) {
            this.src1 =
              this.$base +
              "/download/assessmentReport/" +
              item.routeChartImg +
              "?" +
              new Date().getTime();
          }
          if (item.assessmentReportImg) {
            this.src2 =
              this.$base +
              "/download/assessmentReport/" +
              item.assessmentReportImg +
              "?" +
              new Date().getTime();
          }

          this.assessmentReportImg = item.assessmentReportImg;
          this.fillShip = item.fillShip;
          this.reportName = item.reportName;
          this.completionStatus = item.completionStatus;
          this.completionTime = item.completionTime;
          this.assessCompany = item.assessCompany;
          this.startPoint = item.startPoint;
          this.channel = item.channel;
          this.reportNum = item.reportNum;
          this.totalVoyage = item.totalVoyage;
          this.voyageTime = item.voyageTime;
          this.destination = item.destination;

          this.id = a;
          this.compare = JSON.stringify({
            fillShip: item.fillShip,
            reportName: item.reportName,
            completionStatus: item.completionStatus,
            completionTime: item.completionTime,
            assessCompany: item.assessCompany,
            startPoint: item.startPoint,
            channel: item.channel,
            destination: item.destination,
            reportNum: item.reportNum,
            routeChartImg: item.routeChartImg,
            assessmentReportImg: item.assessmentReportImg,
            totalVoyage: item.totalVoyage,
            voyageTime: item.voyageTime,
          });
        }
        this.show = "block";
      });
    },

    // 删除数据
    deleteOne(a) {
      this.tableData.forEach((item) => {
        if (item.id == a) {
          if (item.routeChartImg) {
            this.old.push(item.routeChartImg);
          }
          if (item.assessmentReportImg) {
            this.old.push(item.assessmentReportImg);
          }
        }
      });
      // let that = this;
      this.$alert("确定删除这条信息？", {
        confirmButtonText: "确定",
        callback: (action) => {
          if (action == "confirm") {
            service({
              method: "delete",
              url: `/assessment-report/${a}`,
            })
              .then((r) => {
                if (r.status == "SUCCESS") {
                  this.$message({
                    type: "success",
                    message: "删除成功",
                  });
                  this.deleteRomoteOldFile();
                  if (this.currentNum == 1 && this.page > 1) {
                    this.page--;
                  }
                  this.getRenderList();
                  this.show = "none";
                }
              })
              .catch((err) => {
                this.$message({
                  type: "danger",
                  message: "出错了！",
                });
              });
          } else {
            this.$message({
              type: "info",
              message: "取消删除",
            });
          }
        },
      });
    },
    // 弹窗确认按钮
    sureAdd() {
      this.data.fillShip = this.fillShip;
      this.data.reportName = this.reportName;
      this.data.completionStatus = this.completionStatus;
      this.data.completionTime = this.completionTime;
      this.data.assessCompany = this.assessCompany;
      this.data.startPoint = this.startPoint;
      this.data.channel = this.channel;
      this.data.destination = this.destination;
      this.data.reportNum = this.reportNum;
      this.data.routeChartImg = this.routeChartImg;
      this.data.assessmentReportImg = this.assessmentReportImg;
      this.data.id = this.id;
      this.data.totalVoyage = this.totalVoyage;
      this.data.voyageTime = this.voyageTime;
      this.data.type = this.type;

      if (this.addOrEdit == "编辑") {
        service({
          method: "put",
          data: this.data,
          url: "/assessment-report",
        })
          .then((r) => {
            if (r.status == "SUCCESS") {
              this.$message({
                type: "success",
                message: "修改成功",
              });
              if (this.old.length > 0) {
                this.deleteRomoteOldFile(this.old);
              }

              this.getRenderList();
              this.show = "none";
              this.clearCanShu();
            } else {
              this.$message({
                type: "warning",
                message: r.error,
              });
            }
          })
          .catch((err) => {
            this.$message({
              type: "info",
              message: "出错了！",
            });
          });
      } else {
        service({
          method: "post",
          data: this.data,
          url: "/assessment-report",
        })
          .then((r) => {
            if (r.status == "SUCCESS") {
              this.$message({
                type: "success",
                message: "新增成功",
              });

              this.getRenderList();
              this.show = "none";
              this.clearCanShu();
            } else {
              this.$message({
                type: "warning",
                message: r.error,
              });
            }
          })
          .catch((err) => {
            this.$message({
              type: "info",
              message: "出错了！",
            });
          });
      }
    },

    // 关闭弹窗
    close() {
      if (this.new.length > 0) {
        this.deleteRomoteNewFile();
      }

      this.show = "none";
      this.show1 = "none";
      this.clearCanShu();
      this.uploadfile = "none";
      this.uploadfile1 = "none";
      this.changeFileUp = "none";
      this.upFileList = [];
      this.upFileListName = [];
      this.old = [];
    },
    // 新增
    addOne() {
      this.addOrEdit = "新增";
      // this.$refs["dialog"].style.display = show;
      this.show = "block";
    },
    // 导出文件
    getFileName() {
      let date = new Date();
      let year = date.getFullYear().toString();
      let month =
        date.getMonth() + 1 > 9
          ? date.getMonth() + 1
          : "0" + (date.getMonth() + 1);
      let day =
        date.getDate() > 10 ? date.getDate().toString() : "0" + date.getDate();
      let hour =
        date.getHours() > 10
          ? date.getHours().toString()
          : "0" + date.getHours();
      let min =
        date.getMinutes() > 10
          ? date.getMinutes().toString()
          : "0" + date.getMinutes();
      date = null;
      return `${year}${month}${day}${hour}${min}`;
    },
    async getExcelFile() {
      let that = this;
      let time = this.getFileName();
      this.token = sessionStorage.getItem("token");
      this.token = JSON.parse(this.token);
      axios({
        method: "get",
        url: this.$loadFile + "/assessment-report/export",
        responseType: "blob", // 关键：设置响应类型为blob
        params: {
          fileName: "船舶证书",
          type: this.type,
        },
        headers: {
          token: that.token,
        },
      })
        .then((response) => {
          const url = window.URL.createObjectURL(new Blob([response.data]));
          // 创建一个隐藏的<a>标签，并设置其href属性为上面创建的URL
          const link = document.createElement("a");
          link.href = url;

          link.download = "通航" + this.pageName + time + ".xls"; // 替
          document.body.appendChild(link);

          link.click();

          document.body.removeChild(link);

          window.URL.revokeObjectURL(url);
        })
        .catch((error) => {
          this.$message({
            message: "文件下载失败",
            type: "info",
          });
        });
    },
    sendMessage() {
      let res = rename();
      EventBus.emit("custom-event", res);
    },
    // 获取列表数据
    async getRenderList() {
      let data = {
        page: this.page,
        size: this.size,
        type: this.type,
      };
      await service({
        methods: "get",
        url: "assessment-report/find-one-page",
        params: data,
      })
        .then((e) => {
          this.totalPages = e.data.totalPages;
          this.totalNumber = e.data.totalElements;
          if (this.totalPages == 0) {
            this.totalPages = 1;
          }
          if (this.page < this.totalPages) {
            this.color1 = "#268FDE";
          } else {
            this.color1 = "#EBEBEB";
          }
          if (this.page == 1) {
            this.color = "#EBEBEB";
          } else {
            this.color = "#268FDE";
          }
          this.tableData = e.data.content;
          this.currentNum = e.data.numberOfElements;
          this.src1 = "";
          this.src2 = "";
        })
        .catch((err) => {});
    },

    clearCanShu() {
      this.fillShip = "";
      this.reportName = "";
      this.completionStatus = "";
      this.completionTime = "";
      this.assessCompany = "";
      this.startPoint = "";
      this.channel = "";
      this.destination = "";
      this.reportNum = "";
      this.id = "";
      this.upFileList = [];
      this.upFileListName = [];
      this.routeChartImg = "";
      this.assessmentReportImg = "";
      this.totalVoyage = "";
      this.voyageTime = "";
      this.src1 = "";
      this.src2 = "";
      this.data = {
        fillShip: "",
        reportName: "",
        completionStatus: "",
        completionTime: "",
        assessCompany: "",
        startPoint: "",
        channel: "",
        destination: "",
        reportNum: "",
        routeChartImg: "",
        assessmentReportImg: "",
        type: this.type,
        totalVoyage: "",
        voyageTime: "",
      };
    },

    clickLastPage() {
      if (this.page > 1) {
        this.page--;
        if (this.page == 1) {
          this.color = "#EBEBEB";
        } else {
          this.color = "#268FDE";
        }
        if (this.page < this.totalPages) {
          this.color1 = "#268FDE";
        }
        this.getRenderList();
      } else {
        this.color = "#EBEBEB";
      }
    },
    clickNextPage() {
      if (this.page < this.totalPages) {
        this.page++;
        this.color = "#268FDE";
        if (this.page == this.totalPages) {
          this.color1 = "#EBEBEB";
        } else {
          this.color1 = "#268FDE";
        }
      }
      this.getRenderList();
    },
    handSize() {
      if (window.innerWidth > 630) {
        if (this.$store.state.width == 200) {
          this.tableWidth = (window.innerWidth - 170) * 0.985 - 20 + "px";
        } else if (this.$store.state.width == 90) {
          this.tableWidth = (window.innerWidth - 60) * 0.985 - 20 + "px";
        }
      } else {
        this.tableWidth = window.innerWidth - 30 + "px";
      }
    },
  },
  watch: {
    "$store.state.width"(newVal, oldVal) {
      //对数据执行操作
      if (window.innerWidth > 630) {
        if (newVal == 90) {
          this.tableWidth = (window.innerWidth - 60) * 0.985 - 20 + "px";
        } else if (newVal == 200) {
          this.tableWidth = (window.innerWidth - 170) * 0.985 - 20 + "px";
        }
      }
    },
  },

  created() {
    this.pageName = this.$route.query.name;
    this.type = this.$route.query.type;
    this.sendMessage();
    this.getRenderList();
  },
  beforeMount() {
    if (window.innerWidth > 630) {
      if (this.$store.state.width == 200) {
        this.tableWidth = (window.innerWidth - 170) * 0.985 - 20 + "px";
      } else if (this.$store.state.width == 90) {
        this.tableWidth = (window.innerWidth - 60) * 0.985 - 20 + "px";
      }
    } else {
      this.tableWidth = window.innerWidth - 30 + "px";
    }
  },
  mounted() {
    let that = this;
    this.getRenderList();

    // this.sendMessage();
    window.addEventListener("resize", this.handSize);
  },
  beforeUnmount() {
    window.removeEventListener("resize", this.handSize);
  },
};
</script>
<style lang="less" scoped>
.addfile {
  width: 100%;
  height: 40px;
  font-size: 15px;
}
.addfile::file-selector-button {
  width: 100%;
  height: 4vh;
  background-color: #1e9fff;
  border: 1px solid #1e9fff;
  border-radius: 3px;
  cursor: pointer;
  color: #fff;
  font-size: 15px;
}
.fileName {
  font-size: 15px;
  color: black;
  height: 3vh;
  line-height: 3vh;
  width: 100%;
  text-align: center;
}
.manyInput::-webkit-scrollbar {
  width: 5px; /* 自定义滚动条的宽度 */
  height: 5px; /* 如果需要自定义垂直滚动条的高度 */
}

/* 自定义滚动条滑块的颜色 */
.manyInput::-webkit-scrollbar-thumb {
  background-color: #f1f1f1;
  border-radius: 10px; /* 可选：为滚动条滑块添加圆角 */
}

/* 自定义滚动条轨道的颜色 */
.manyInput::-webkit-scrollbar-track {
  background-color: white;
  border-radius: 10px; /* 可选：为滚动条轨道添加圆角 */
}
.manyInput {
  width: 1100px;
  height: 80vh;
  overflow: auto;

  margin: auto;
  margin-top: 20px;
  display: flex;
  flex-wrap: wrap;
  justify-content: space-between;
  // overflow: scroll;
  .iuptInnerContain {
    width: 390px;
    // height: 230px;
    height: 520px;
    display: flex;
    flex-wrap: wrap;

    .inputInner {
      width: 375px;
      height: 35px;
      // background: blue;
      margin-right: 10px;
      margin-top: 10px;
      display: flex;
      align-items: center;
      position: relative;
      // justify-content: space-between;
      color: #365488;
      .name {
        width: 150px;
        height: 100%;
        line-height: 4vh;
        text-align: right;
        font-size: 15px;
      }

      .inputContainer {
        width: 210px;
        margin-left: 5px;
      }
      .el-input__inner {
        background: white !important;
      }
      input {
        width: 220px;
        height: 34px;
        margin-left: 5px;
        border-radius: 5px;
        text-indent: 1em;
        outline: none;
        border: none;
        background: white !important;
        color: #365488;
        border: 1px solid #dcdfe6;
      }
      input::-webkit-input-placeholder {
        color: #a8abb2;
      }
      input[type="date"] {
        // padding: 5px;
        color: #365488;
        text-align: left;
        // border: 1px solid #365488;
        border-radius: 4px;
        // background-color: #fff;
        box-sizing: border-box; /* 确保内边距和边框不会影响元素的总宽度 */
      }
      // input[type="number"] {
      //   appearance: textfield;
      //   -moz-appearance: textfield;
      // }
      // 　　input[type="number"]::-webkit-inner-spin-button,
      // 　　input[type="number"]::-webkit-outer-spin-button {
      //   -webkit-appearance: none;
      //   margin: 0;
      // }
    }

    .el-date-picker .el-picker-panel {
      background-color: white !important; /* 你想要的背景颜色 */
    }
  }
}
.dialogText {
  margin: auto;
  width: 50%;
  line-height: 4vh;
  font-size: 25px;
  color: black;
  // text-indent: 10px;
  text-align: center;
  // font-size: 20px;
  font-weight: 800;
}

.dialog,
.dialog1 {
  width: 100%;
  height: 100%;
  background: #dfe6e8;
  position: absolute;
  top: 0;
  left: 0;
  display: none;
  z-index: 100;
}

.loadHomeWork {
  overflow: hidden;
  width: 100%;
  height: 100%;
  position: relative;
  .loadHomeWorkIneer {
    width: 98.5%;
    height: 91vh;
    margin: auto;
    margin-top: 1vh;
    background: white;
    overflow-y: auto;
    overflow-x: auto;

    .loadSecond {
      width: 280px;

      color: black;
      text-align: center;
      line-height: 33px;
      color: black;
      display: flex;
      align-items: center;
      justify-content: space-between;
      margin-left: 10px;
      font-size: 15px;
      .topName {
        width: 90px;
        line-height: 33px;
        background: #67c23a;
        border-radius: 5px;
        a {
          display: block;
          width: 90px;
          line-height: 33px;
          text-decoration: none;
          color: white;
        }
      }
      .topName:nth-child(3) {
        background: #242121;
      }
    }
    // .loadExcel {
    //   width: 300px;
    //   margin-top: 10px;
    //   margin-left: 10px;

    //   height: 20px;
    //   display: flex;
    //   align-items: center;
    //   justify-content: space-between;
    //   .button {
    //     width: 60px;
    //     line-height: 20px;
    //     font-size: 18px;
    //     text-align: center;
    //   }
    // }
  }
  // background: blue;
}
.table {
  width: 98.5%;
  margin: auto;
  // margin-top: 2vh;
  height: 65vh;
  // background: red;
}
.pictureContainner {
  width: 700px;
  .inputInner {
    width: 375px;
    height: 35px;
    // background: blue;
    margin-right: 10px;
    margin-top: 10px;
    display: flex;
    align-items: center;
    position: relative;
    // justify-content: space-between;
    color: #365488;
    .name {
      width: 150px;
      height: 100%;
      line-height: 4vh;
      text-align: right;
      font-size: 15px;
    }
    .name6 {
      width: 100px;
      height: 100%;
      line-height: 4vh;
      text-align: right;
      font-size: 15px;
      text-align: center;
      color: white;
      border-radius: 5px;
      background: #0470c1;
      // margin-right: 10px;
    }

    .inputContainer {
      width: 210px;
      margin-left: 5px;
    }
    .el-input__inner {
      background: white !important;
    }
    input {
      width: 220px;
      height: 34px;
      margin-left: 5px;
      border-radius: 5px;
      text-indent: 1em;
      outline: none;
      border: none;
      background: white !important;
      color: #365488;
      border: 1px solid #dcdfe6;
    }
    input::-webkit-input-placeholder {
      color: #a8abb2;
    }
    input[type="date"] {
      // padding: 5px;
      color: #365488;
      text-align: left;
      // border: 1px solid #365488;
      border-radius: 4px;
      // background-color: #fff;
      box-sizing: border-box; /* 确保内边距和边框不会影响元素的总宽度 */
    }
    // input[type="number"] {
    //   appearance: textfield;
    //   -moz-appearance: textfield;
    // }
    // 　　input[type="number"]::-webkit-inner-spin-button,
    // 　　input[type="number"]::-webkit-outer-spin-button {
    //   -webkit-appearance: none;
    //   margin: 0;
    // }
  }
  .tonghangImgContain {
    width: 100%;
    margin: auto;
    display: flex;
    align-items: center;
    justify-content: center;
    border: none;
    margin-top: 10px;
    height: 400px;
    img {
      width: 100%;
      height: 100%;
      border: none;
    }
  }
  .el-date-picker .el-picker-panel {
    background-color: white !important; /* 你想要的背景颜色 */
  }
}
@media (min-width: 0px) and (max-width: 960px) {
  .manyInput {
    width: 375px !important;
    display: block !important;
    .inputInner {
      margin: auto !important;
      // margin-top: 10px !important;
    }
  }
  .closeAndSrue {
    width: 110px;
  }
}
</style>
